package mains;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

import app.Payment;

public class Main9QueryParameters {

    private static final String PERSISTENCE_UNIT_NAME = "CashM";
    private static EntityManagerFactory factory;

    public static void main(String[] args) {
	factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
	EntityManager em = factory.createEntityManager();

	List<Payment> listM = null;
	TypedQuery<Payment> queryN = em
		.createQuery("SELECT p FROM Payment p Where p.total > :limit",
			Payment.class);
	try {
	    queryN.setParameter("limit", 250.0);
	    listM = queryN.getResultList();
	} finally {
	    em.close();
	}
	for (Payment p : listM) {
	    System.out.println(p.toString());
	}

    }

}
